package architect.springcloud.feign.service;

import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

/**
 * 容错类
 *
 * @author guanxin
 * @date 2018/4/18 19:05
 */

@Component
@Slf4j
public class HystrixSmsServiceFailFactory implements FallbackFactory<SmsService> {

    @Override
    public SmsService create(Throwable throwable) {
        return new SmsService() {
            @Override
            public String sendSms(String content) {
                log.error(throwable.getMessage(), throwable);
                return "Call sendSms fail, content = " + content;
            }
        };
    }
}
